package com.zipking.cloud.springbootmybatis.persistance.service.impl;
import java.io.Serializable;
import java.util.Date;

import com.baomidou.mybatisplus.core.enums.SqlMethod;
import com.baomidou.mybatisplus.core.metadata.TableInfo;
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.core.toolkit.ReflectionKit;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.google.common.collect.Lists;
import com.zipking.cloud.springbootmybatis.persistance.entity.MsgLog;
import com.zipking.cloud.springbootmybatis.persistance.mapper.MsgLogMapper;
import com.zipking.cloud.springbootmybatis.persistance.service.IMsgLogExtService;
 import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.binding.MapperMethod;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
@Slf4j
@Service
public class MsgLogExtServiceImpl extends MyServiceImpl<MsgLogMapper, MsgLog> implements IMsgLogExtService{
    @Override
    public void saveBatchMsgLog(){
        List<MsgLog> users = IntStream.rangeClosed(1, 1013)
                .mapToObj(id -> {
                    MsgLog msgLog = new MsgLog();
                    msgLog.setMsgId(IdWorker.getTimeId());
                    msgLog.setMsg(id+"");
                    msgLog.setExchange(id+"");
                    msgLog.setRoutingKey(id+"");
                    msgLog.setStatus(0);
                    msgLog.setTryCount(0);
                    msgLog.setNextTryTime(new Date());
                    msgLog.setCreateTime(new Date());
                    msgLog.setUpdateTime(new Date());

                    return msgLog;
                })
                .collect(Collectors.toList());




    }

    @Override
    public void updateBatchMsgLog() {
        List<MsgLog> users = Lists.newArrayList();
        MsgLog msgLog = new MsgLog();
        msgLog.setMsgId("1775843061110681600");
        msgLog.setMsg("1775843061110681600");
        msgLog.setExchange("1775843061110681600");
        msgLog.setRoutingKey("1775843061110681600");
        msgLog.setStatus(0);
        msgLog.setTryCount(0);
        msgLog.setNextTryTime(new Date());
        msgLog.setCreateTime(new Date());
        msgLog.setUpdateTime(new Date());
        users.add(msgLog);
        boolean b = this.saveOrUpdateBatch(users, 400);
        System.out.println("b = " + b);
    }

}
